package com.axend.aerosense.room.ui.adapter;

import androidx.databinding.DataBindingUtil;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.axend.aerosense.base.bean.RoomTypeBean;
import com.axend.aerosense.room.R;
import com.axend.aerosense.room.databinding.RoomLayoutAddRoomItemBinding;

import org.jetbrains.annotations.NotNull;

/**
 * 房间模块主页列表
 * @author ChenHongWei
 * @date :2020/12/29 10:51
 */

public class RoomCreateRoomListAdapter extends BaseQuickAdapter<RoomTypeBean, BaseViewHolder> {
    RoomLayoutAddRoomItemBinding bindingView;

    public RoomCreateRoomListAdapter() {
        super(R.layout.room_layout_add_room_item);
    }

    @Override
    protected void onItemViewHolderCreated(@NotNull BaseViewHolder viewHolder, int viewType) {
        bindingView = DataBindingUtil.bind(viewHolder.itemView);

    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, RoomTypeBean typeBean) {
        if(null == baseViewHolder){
            return;
        }
        bindingView = baseViewHolder.getBinding();
        int imageId = R.drawable.room_icon_livingroom;
        switch (typeBean.getRoomType()){
            case 1:
                imageId = R.drawable.room_icon_livingroom;
                break;
            case 2:
                imageId = R.drawable.room_icon_bedroom;
                break;
            case 3:
                imageId = R.drawable.room_icon_bathroom;
                break;
            case 4:
                imageId = R.drawable.room_icon_kitchen;
                break;
            case 5:
                imageId = R.drawable.room_icon_restaurant;
                break;
            case 6:
                imageId = R.drawable.room_icon_study;
                break;
            case 7:
                imageId = R.drawable.room_icon_otherroom;
                break;
            default:
                imageId = R.drawable.room_icon_otherroom;
        }
        bindingView.roomIvRoomType.setImageResource(imageId);
        bindingView.roomTvRoomName.setText(typeBean.getRoomName());

    }
}
